package com.tql.pandian.service.impl;

import com.ruoyi.common.core.constant.CommonUtil;
import com.ruoyi.common.datasource.annotation.Master;
import com.ruoyi.common.datasource.annotation.Slave;
import com.tql.pandian.entity.analysis.TqlCaseAnlasysEntity;
import com.tql.pandian.entity.analysis.dto.BillFoodReportDayDto;
import com.tql.pandian.entity.analysis.vo.FoodReportVo;
import com.tql.pandian.entity.analysis.vo.RealSummaryVo;
import com.tql.pandian.entity.analysis.vo.ShopBillListVo;
import com.tql.pandian.entity.vo.CaseAnalsysDto;
import com.tql.pandian.mapper.AnotherDataBaseMapper;
import com.tql.pandian.service.IAnotherDataBaseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class AnotherDataBaseService implements IAnotherDataBaseService {

    @Autowired
    private AnotherDataBaseMapper anotherDataBaseMapper;

    @Slave
    @Override
    public List<ShopBillListVo> getShopBillListVo(Map map) {
        return anotherDataBaseMapper.selectShopBillList(map);
    }

    @Slave
    @Override
    public List<RealSummaryVo> getRealSummary(String dateTime, String tableName) {
        return anotherDataBaseMapper.selectRealSummary(dateTime, tableName);
    }

    @Slave
    @Override
    public List<BillFoodReportDayDto> getFoodReportVoList(Long paramTime, String tableName, String deptId) {
        return anotherDataBaseMapper.selectFoodReportList(paramTime,tableName,deptId);
    }

    @Slave
    @Override
    public int saveCaseAnlasys(TqlCaseAnlasysEntity bean, String tableName){
        return anotherDataBaseMapper.insertCaseAnlasys(bean, tableName);
    }

    @Slave
    @Override
    public int saveListCaseAnlasys(List<TqlCaseAnlasysEntity> list, String tableName){
        return anotherDataBaseMapper.insertBatchCaseAnlasys(list, tableName);
    }


    @Override
    @Master
    public List<CaseAnalsysDto> findStapCodeOfDeptCode() {
        return anotherDataBaseMapper.findStapCodeOfDeptCode();
    }

    @Override
    @Slave
    public List<CaseAnalsysDto> findCurrentCaseAndCurrentConsume(String[] deptCodeStapCodeArr, int month) {
        String tabName= CommonUtil.TABLE_CASE_ANLASYS+month;
        return anotherDataBaseMapper.findCurrentCaseAndCurrentConsume(deptCodeStapCodeArr,tabName);
    }

    @Override
    @Slave
    public List<CaseAnalsysDto> findCurrentConsume(Long reportDate, int month) {
        String tabName= CommonUtil.TQL_STAP_OUT_CHANGE+month;
        return anotherDataBaseMapper.findCurrentConsume(reportDate,tabName);
    }

    @Override
    @Slave
    public List<CaseAnalsysDto> findCurrentInum(String s, int month) {
        String tabName= CommonUtil.TQL_STAP_IN_CHANGE+month;
        return anotherDataBaseMapper.findCurrentInum(s,tabName);
    }

    @Override
    @Slave
    public void batchInsert(List<CaseAnalsysDto> list, int month1) {
        String tabName= CommonUtil.TABLE_CASE_ANLASYS+month1;
        anotherDataBaseMapper.batchInsert(list,tabName);

    }

    @Override
    @Master
    public List<BillFoodReportDayDto> findDishFood(List<String> foodCodes, String deptId) {
       return  anotherDataBaseMapper.findDishFood(foodCodes,deptId);
    }
}
